﻿//by  张海军 710605420@qq.com
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TestParticle : Mask {
    
    public RectTransform rect;
    public ParticleSystem particle;
    // Use this for initialization
    void Start()
    {
        Refresh();
    }
    private void Refresh()
    {
        Vector3[] vecCorners = new Vector3[4];
        rect.GetWorldCorners(vecCorners);
        Vector4 vector4 = new Vector4(vecCorners[0].x, vecCorners[0].y, vecCorners[2].x, vecCorners[2].y);

        Renderer rtr = particle.GetComponent<Renderer>();

        Material m = rtr.sharedMaterial;


        m.SetVector("_ClipRect", vector4);
    }
    protected override void OnRectTransformDimensionsChange()
    {
        base.OnRectTransformDimensionsChange();
        Refresh();
    }
    // Update is called once per frame
    void Update () {
		
	}
}
